﻿using System.Collections.Generic;
using System.Configuration;
using System.Web;

namespace KL.UFrame.Core.Configuration
{
    /// <summary>
    /// 全局配置文件
    /// </summary>
    public static class AppConfiguration
    {
        #region App Settings

        /// <summary>
        /// 服务器绑定的域名或者IP
        /// </summary>
        public static readonly string Host = ConfigurationManager.AppSettings["host"];

        #endregion

        #region 构造函数

        static AppConfiguration()
        {
            var config = ConfigurationManager.AppSettings;

            AppName = config["AppName"] ?? "KLFM";
            var len = 1048576;
            var lenString = config["FileUploadMaxLength"];
            if (!string.IsNullOrEmpty(lenString))
            {
                int.TryParse(lenString, out len);
            }
            FileUploadMaxLength = len;

           SqlTextPath= HttpContext.Current.Server.MapPath("~/App_Data/Sql/");
        }

        #endregion

        #region 常量

        /// <summary>
        /// Http请求中，存储加密token的header名
        /// </summary>
        public const string OpenIdHeaderName = "X-ACCESS_TOKEN";

        /// <summary>
        /// 用户角色缓存键
        /// </summary>
        public const string OAuthUserRolesKey = "OAuthUserRolesKey_";

        public static string AppName { get; private set; }

        public static int FileUploadMaxLength { get; private set; }

        public const string DefaultUserHeadImageUrl = "img/a0.jpg";
        public const string ProfileUploadPath = @"/Upload/Profile/";
        public const string FileUploadPath = @"/Upload/";
        public const string TempPath = @"/Upload/Tmp/";
        public const string ForbidenRegexString = @"^[^&\<\>\\/\*\$\&\|\~\!\?\[\]]+$";

        public static string SqlTextPath { get; private set; }

        public static readonly string DbConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

        #endregion

        #region Url

        #endregion

        #region 微信配置

        public static  readonly string WxAppId= ConfigurationManager.AppSettings["WxAppId"];
        public static readonly string WxAppSecret = ConfigurationManager.AppSettings["WxAppSecret"];
        public static readonly string WxAppCode = ConfigurationManager.AppSettings["WxAppCode"];



        #endregion
      
    }
}